package com.warehouse.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * 时间差工具类
 */
public class TimeD {
    public static int getHours(String oldTime,String nowTime){
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH-mm");
        long time1 = 0;
        long time2 = 0;
        try {
            time1 = format.parse(oldTime).getTime();
            time2 = format.parse(nowTime).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        long seconds =(time2-time1)/(1000); //共计秒数
        return (int) seconds / 3600; //共计小时数
    }
}
